$(function(){
	
	/**
	 * 首页类型 hover事件效果处理
	 */
	$("#types li").hover(function(){
		var locationUuid=$(this).find(".obj").attr("value");
		$(".more-types").data("locationUuid",locationUuid).show();
	},function(){
		$(".more-types").hide();
	})
	
	$(".more-types").hover(function(){
		$(this).show();
		var locationUuid = $(this).data("locationUuid");
		$("#types .obj[value="+locationUuid+"]").parent().parent().css("background-color","RGB(250,174,0)");
	},function(){
		var locationUuid = $(this).data("locationUuid");
		$("#types .obj[value="+locationUuid+"]").parent().parent().css("background-color","");
		$(this).hide();
	})
	
	/**
	 * 首页 类型点击事件
	 */
	$(".more-types").delegate(".list-inline li","click",function(){
		var locationUuid = $(".more-types").data("locationUuid");
		var data = {
			curPage:1,
			pageSize:9,
			locationUuid:locationUuid
		};
		
		var queryUrl = "curPage=1&pageSize=9&locationUuid="+locationUuid;
		
		var field=$(this).attr("field");
		
		if(field=="styleUuid"){
			data.styleUuid = $(this).attr("value") ;
			queryUrl += "&styleUuid="+data.styleUuid;
		}else if(field=="productTypeUuid"){
			data.productTypeUuid = $(this).attr("value") ;
			queryUrl += "&productTypeUuid="+data.productTypeUuid;
		}else if(field=="openUuid"){
			data.openUuid = $(this).attr("value") ;
			queryUrl += "&openUuid="+data.openUuid;
		}
		/*else if(field=="price"){
			data.minPrice = $(this).attr("min");
			data.maxPrice = $(this).attr("max");
			if(data.minPrice){
				queryUrl += "&minPrice="+data.minPrice;
			}
			if(data.maxPrice){
				queryUrl += "&maxPrice="+data.maxPrice;
			}
		}else if(field=="area"){
			data.minArea = $(this).attr("min");
			data.maxArea = $(this).attr("max");
			queryUrl += "&minArea="+data.minArea;
			queryUrl += "&maxArea="+data.maxArea;
		}*/
		
		window.open("/"+Udwin.appName+"/product/list?"+queryUrl);
	
	});
	
	/**
	 * 产品详情
	 */
	$("body").delegate(".productImg","click",function(){
		var productUuid = $(this).attr("value");
		window.open("/"+Udwin.appName+"/product/detail/"+productUuid);
	})
	
	/**
	 * 更多产品推荐
	 */
	$("body").delegate("#moreProduct","click",function(){
		window.open("/"+Udwin.appName+"/product/list");
	})
	/**
	 * 更多门
	 */
	$("body").delegate("#moreDoor","click",function(){
		window.open("/"+Udwin.appName+"/product/list?productTypeUuid=2");
	})
	/**
	 * 更多窗
	 */
	$("body").delegate("#moreWindow","click",function(){
		window.open("/"+Udwin.appName+"/product/list?productTypeUuid=1");
	})
	/**
	 * 更多阳光房
	 */
	$("body").delegate("#moreShineRoom","click",function(){
		window.open("/"+Udwin.appName+"/product/list?productTypeUuid=3");
	})
	
	/**
	 * 定制量尺
	 */
	$("body").delegate("#dzlc","click",function(){
		window.open("/"+Udwin.appName+"/resources/html/dzlc.html");
	})
	
	//免费预约量尺
	$("body").delegate("#freeCustom","click",function(){
		var data = {};
		data.name = $("form #name").val().trim();
		data.phone = $("form #phone").val().trim();
		data.province = $("form #province").val().trim();
		data.city = $("form #city").val().trim();
		
		if(data.name==''||data.phone==''){
			alert('请填写姓名和手机号码！')
			return ;
		}
		
		$.ajax({
			url:"/"+Udwin.appName+"/order/addOrder",
			contentType: "application/json; charset=utf-8",
			method:"POST",
			dataType: "json",
			data:JSON.stringify(data),
			success:function(data){
				console.log(data);
			}
		})
	})
})